package com.meatball.game.util

import com.meatball.game.data.RandomUser
import kotlin.random.Random

/**
 * TODO 获取随机的用户与头像
 *
 * @return
 */
fun generatorRandomUser() : RandomUser {
    return RandomUser(
            id = generateNoDashUUID(),
            name = generateRandomName(),
            avatar = gravatarUrl()
    )
}

val characters = arrayOf("美", "明", "小", "嘉", "浩", "宇", "娜", "豪", "婷", "玲", "龙", "宝", "洁", "琼", "华", "月", "欣", "琳")
val surnames = arrayOf("赵", "钱", "孙", "李", "周", "吴", "郑", "王", "冯", "陈", "褚", "卫", "蒋", "沈", "韩", "杨")
fun generateRandomName(): String {
    val random = Random

    val name = StringBuilder()
    val nameLength = random.nextInt(2) + 1 // Random name length of 1 or 2 characters
    val surnameIndex = random.nextInt(surnames.size)
    name.append(surnames[surnameIndex])

    for (j in 0 until nameLength) {
        val randomIndex = random.nextInt(characters.size)
        name.append(characters[randomIndex])
    }

    return name.toString()
}

val avatars = arrayOf(
        "https://meatball.org.cn:8000/images/2024/03/07/v2-3441507db209572e47109f8ca3f534de_r.jpg",
        "https://meatball.org.cn:8000/images/2024/03/07/v2-615498e4b1e1285f40a3c6283d54e168_r.jpg",
        "https://meatball.org.cn:8000/images/2024/03/07/v2-96e38ba70a23189737b0dca1d8fb315f_r.jpg",
        "https://meatball.org.cn:8000/images/2024/03/07/v2-72d0317a5dfb934a42974c32a8bda4bb_r.jpg",
        "https://meatball.org.cn:8000/images/2024/03/07/v2-9c0320d6882702265bca8dd2ccb87ecd_r.jpg",
        "https://meatball.org.cn:8000/images/2024/03/07/20200120114229_ytdj2.jpg",
        "https://meatball.org.cn:8000/images/2024/03/07/v2-6b9ade8a3dce476f0c56e9a52aa89d8b_r.jpg",
        "https://meatball.org.cn:8000/images/2023/04/13/R.jpg",
        "https://meatball.org.cn:8000/images/2023/04/13/R-1.jpg",
        "https://meatball.org.cn:8000/images/2023/04/13/f0a0-knqqqmu1606334.jpg"
)
fun gravatarUrl(): String {
//    val randomId = (1..1000).random().toString()
//    return "https://robohash.org/$randomId"
//    return "https://cdn.seovx.com/d/?mom=302"
    return avatars.random()
}